package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: xrl
 * @Date: 2022/10/13  12:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 素材上传
     *
     * @param multipartFile
     * @return
     */
    @PostMapping("/upload_picture")
    public ResponseResult upload(MultipartFile multipartFile) {
        return wmMaterialService.upload(multipartFile);
    }

    /**
     * 素材列表查询
     */
    @PostMapping("/list")
    public ResponseResult getList(@RequestBody WmMaterialDto dto) {
        return wmMaterialService.getList(dto);
    }

    /**
     * 删除素材
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult deleteMaterial(@PathVariable Integer id) {
        return wmMaterialService.deleteMaterial(id);
    }
}
